package com.wzt.config;

import com.wzt.service.ChatAssistant;
import dev.langchain4j.model.chat.StreamingChatLanguageModel;
import dev.langchain4j.model.openai.OpenAiStreamingChatModel;
import dev.langchain4j.service.AiServices;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import java.time.Duration;

@Configuration(proxyBeanMethods = false)
public class ChatLanguageModelConfig
{
    @Bean
    public StreamingChatLanguageModel streamingChatLanguageModel(){
        return OpenAiStreamingChatModel.builder()
                .apiKey(System.getenv("LANGCHAIN4J_KEY"))
                //.modelName("qwen-vl-max")
                .modelName("qwen-turbo-0624")
                .timeout(Duration.ofSeconds(10))
                .baseUrl("https://dashscope.aliyuncs.com/compatible-mode/v1")
                .build();
    }

//    @Bean
//    @Primary
//    public StreamingChatLanguageModel streamingChatLanguageModelWithDeepSeek(){
//        return OpenAiStreamingChatModel.builder()
//                .apiKey("")
//                .modelName("deepseek-chat")
//                .baseUrl("https://api.deepseek.com/v1")
//                .build();
//    }

    @Bean
    public ChatAssistant chatAssistant(StreamingChatLanguageModel deepseekChatModel){
        return AiServices.create(ChatAssistant.class, deepseekChatModel);
    }

}